//
//  YHOptionTitleTextViewInputTableViewCell.m
//  ScriptKill
//
//  Created by 林宁宁 on 2021/4/29.
//  Copyright © 2021 优智汇. All rights reserved.
//

#import "YHOptionTitleTextViewInputTableViewCell.h"
#import "UITextView+YHInputLimit.h"
#import "UIFont+YH.h"
#import "UIView+YHInputAccessory.h"
#import "NSMutableAttributedString+YH.h"

@implementation YHOptionTitleTextViewInputTableViewCell


-(void)yh_optionInit{
    
    self.cellTextView = [UITextView new];
    self.cellTextView.backgroundColor = [[UIColor yh_background] lighterColor:0.9];
    self.cellTextView.textAlignment = NSTextAlignmentLeft;
    self.cellTextView.font = [UIFont yh_pfOfSize:14];
    self.cellTextView.textColor = [UIColor yh_h2];
    self.cellTextView.keyboardAppearance = UIKeyboardAppearanceDark;
    [self.cellTextView showAccessoryDown:^{
            
    }];
    [self.cellOptionContentView addSubview:self.cellTextView];
    
    [self.cellTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.cellOptionContentView);
    }];
    
    WS(weakSelf)
    [NSNotificationCenter yh_addObserver:self name:UITextViewTextDidChangeNotification usingBlock:^(NSNotification * _Nonnull note, id  _Nonnull observer) {
        [weakSelf editChangeAction];
    }];
    [NSNotificationCenter yh_addObserver:self name:UITextViewTextDidEndEditingNotification usingBlock:^(NSNotification * _Nonnull note, id  _Nonnull observer) {
        [weakSelf editEndAction];
    }];
}

- (void)editChangeAction{
    if(self.editChangeBlock){
        self.editChangeBlock(self.cellTextView.text);
    }
}

- (void)editEndAction{
    if(self.editEndBlock){
        self.editEndBlock(self.cellTextView.text);
    }
}

@end
